Option Strict On
Option Explicit On

'Copyright (c) 2007-2010, William Severance, Jr., WESNet Designs
'All rights reserved.

'Redistribution and use in source and binary forms, with or without modification, are permitted
'provided that the following conditions are met:

'Redistributions of source code must retain the above copyright notice, this list of conditions
'and the following disclaimer.

'Redistributions in binary form must reproduce the above copyright notice, this list of conditions
'and the following disclaimer in the documentation and/or other materials provided with the distribution.

'Neither the name of William Severance, Jr. or WESNet Designs may be used to endorse or promote
'products derived from this software without specific prior written permission.

'Disclaimer: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
'            OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
'            AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE
'            FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
'            LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
'            INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
'            OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
'            IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

'Although I will try to answer questions regarding the installation and use of this software when
'such questions are submitted via e-mail to the below address, no promise of further
'support or enhancement is made nor should be assumed.

'Developer Contact Information:
'     William Severance, Jr.
'     WESNet Designs
'     679 Upper Ridge Road
'     Bridgton, ME 04009
'     Phone: 207-647-9375
'     E-Mail: bill@wesnetdesigns.com
'     Website: www.wesnetdesigns.com

Imports System
Imports System.Configuration
Imports System.Data
Imports System.Xml.Serialization
Imports DotNetNuke.Entities.Modules

Namespace WESNet.DNN.Modules.EPrayer

    <Serializable(), XmlRoot("Post")> _
    Public Class PostInfo
        Inherits DotNetNuke.Entities.BaseEntityInfo
        Implements DotNetNuke.Entities.Modules.IHydratable

        Private _PostID As Integer = -1
        Private _RequestID As Integer = -1
        Private _Body As String
        Private _CreatedByUser As String
        Private _CreatedByUsername As String
        Private _Signature As String
        Private _LastModifiedByUser As String
        Private _LastModifiedByUsername As String
        Private _SubmittedFor As String
        Private _RelationshipID As Integer
        Private _Relationship As String
        Private _Track As Integer = -1       'tri-state value to allow null implying don't change tracking
        Private _NotifySubject As Boolean
        Private _Distribution As Integer
        Private _IsApproved As Boolean
        Private _ApprovedOnDate As DateTime
        Private _RemoteAddr As String

        'Filled only by GetPostsToModerate from the original post for this request
        Private _IsPraise As Boolean
        Private _Subject As String
        Private _Category As String

        <XmlIgnore()> _
        Public Property PostID() As Integer
            Get
                Return _PostID
            End Get
            Set(ByVal value As Integer)
                _PostID = value
            End Set
        End Property

        <XmlIgnore()> _
        Public Property RequestID() As Integer
            Get
                Return _RequestID
            End Get
            Set(ByVal value As Integer)
                _RequestID = value
            End Set
        End Property

        Public Property Body() As String
            Get
                Return _Body
            End Get
            Set(ByVal value As String)
                _Body = value
            End Set
        End Property

        <XmlIgnore()> _
        Public Property Signature() As String
            Get
                Return _Signature
            End Get
            Set(ByVal value As String)
                _Signature = value
            End Set
        End Property

        Public Property NotifySubject() As Boolean
            Get
                Return _NotifySubject
            End Get
            Set(ByVal value As Boolean)
                _NotifySubject = value
            End Set
        End Property

        <XmlIgnore()> _
        Public Property Track() As Integer
            Get
                Return _Track
            End Get
            Set(ByVal value As Integer)
                _Track = value
            End Set
        End Property

        Public Property SubmittedFor() As String
            Get
                Return _SubmittedFor
            End Get
            Set(ByVal value As String)
                _SubmittedFor = value
            End Set
        End Property

        <XmlIgnore()> _
        Public Property RelationshipID() As Integer
            Get
                Return _RelationshipID
            End Get
            Set(ByVal value As Integer)
                _RelationshipID = value
            End Set
        End Property

        Public Property Relationship() As String
            Get
                Return _Relationship
            End Get
            Set(ByVal value As String)
                _Relationship = value
            End Set
        End Property

        Public Property Distribution() As Integer
            Get
                Return _Distribution
            End Get
            Set(ByVal value As Integer)
                _Distribution = value
            End Set
        End Property

        Public Property IsApproved() As Boolean
            Get
                Return _IsApproved
            End Get
            Set(ByVal value As Boolean)
                _IsApproved = value
            End Set
        End Property

        Public Property ApprovedOnDate() As DateTime
            Get
                Return _ApprovedOnDate
            End Get
            Set(ByVal value As DateTime)
                _ApprovedOnDate = value
            End Set
        End Property

        Public Property RemoteAddr() As String
            Get
                Return _RemoteAddr
            End Get
            Set(ByVal value As String)
                _RemoteAddr = value
            End Set
        End Property

        <XmlIgnore()> _
        Public Property IsPraise() As Boolean
            Get
                Return _IsPraise
            End Get
            Set(ByVal value As Boolean)
                _IsPraise = value
            End Set
        End Property

        <XmlIgnore()> _
        Public Property Subject() As String
            Get
                Return _Subject
            End Get
            Set(ByVal value As String)
                _Subject = value
            End Set
        End Property

        <XmlIgnore()> _
        Public Property Category() As String
            Get
                Return _Category
            End Get
            Set(ByVal value As String)
                _Category = value
            End Set
        End Property

        <XmlIgnore()> _
        Public Shadows Property CreatedByUser() As String
            Get
                Return _CreatedByUser
            End Get
            Set(ByVal value As String)
                _CreatedByUser = value
            End Set
        End Property

        Public Property CreatedByUsername As String
            Get
                Return _CreatedByUsername
            End Get
            Set(ByVal value As String)
                _CreatedByUsername = value
            End Set
        End Property

        <XmlIgnore()> _
        Public Shadows Property LastModifiedByUser() As String
            Get
                Return _LastModifiedByUser
            End Get
            Set(ByVal value As String)
                _LastModifiedByUser = value
            End Set
        End Property

        Public Property LastModifiedByUsername As String
            Get
                Return _LastModifiedByUsername
            End Get
            Set(ByVal value As String)
                _LastModifiedByUsername = value
            End Set
        End Property

        'The following two properties shadow those of the base class BaseEntityInfo to
        'for the purposes of serialization for support of IPortable.

        Public Shadows Property CreatedOnDate As DateTime
            Get
                Return MyBase.CreatedOnDate
            End Get
            Set(ByVal value As DateTime)
                ' Must have setter for serialization
            End Set
        End Property

        Public Shadows Property LastModifiedOnDate As DateTime
            Get
                Return MyBase.LastModifiedOnDate
            End Get
            Set(ByVal value As DateTime)
                ' Must have setter for serialization
            End Set
        End Property

#Region "IHydratable Implementation"

        Public Shadows Sub FillInternal(ByVal dr As System.Data.IDataReader)
            MyBase.FillInternal(dr)
            _PostID = Convert.ToInt32(dr.Item("PostID"))
            _RequestID = Convert.ToInt32(dr.Item("RequestID"))
            _Body = Null.SetNullString(dr.Item("Body"))
            _CreatedByUser = Null.SetNullString(dr.Item("CreatedByUser"))
            _CreatedByUsername = Null.SetNullString(dr.Item("CreatedByUsername"))
            _Signature = Null.SetNullString(dr.Item("Signature"))
            _SubmittedFor = Null.SetNullString(dr.Item("SubmittedFor"))
            _LastModifiedByUser = Null.SetNullString(dr.Item("LastModifiedByUser"))
            _LastModifiedByUsername = Null.SetNullString(dr.Item("LastModifiedByUsername"))
            _IsApproved = Convert.ToBoolean(dr.Item("IsApproved"))
            _NotifySubject = Convert.ToBoolean(dr.Item("NotifySubject"))
            If IsDBNull(dr.Item("Track")) Then
                _Track = -1
            Else
                _Track = Convert.ToInt32(dr.Item("Track"))
            End If
            _ApprovedOnDate = Null.SetNullDateTime(dr.Item("ApprovedOnDate"))
            _RelationshipID = Convert.ToInt32(dr.Item("RelationshipID"))
            _Relationship = Null.SetNullString(dr.Item("Relationship"))
            _Distribution = Convert.ToInt32(dr.Item("Distribution"))
            _RemoteAddr = Null.SetNullString(dr.Item("RemoteAddr"))
        End Sub

        Public Sub Fill(ByVal dr As System.Data.IDataReader) Implements DotNetNuke.Entities.Modules.IHydratable.Fill
            If Not dr Is Nothing Then
                FillInternal(dr)

                'From first (original) Post
                _IsPraise = Convert.ToBoolean(dr.Item("IsPraise"))
                _Subject = Convert.ToString(dr.Item("Subject"))
                _Category = Null.SetNullString(dr.Item("Category"))
            End If
        End Sub

        Public Property KeyID As Integer Implements DotNetNuke.Entities.Modules.IHydratable.KeyID
            Get
                Return _PostID
            End Get
            Set(ByVal value As Integer)
                _PostID = value
            End Set
        End Property
#End Region

    End Class

End Namespace